import request from '@/config/axios'

// 销售订单主 VO
export interface SaleOrderVO {
  id: number // id
  serialNumber: string // 流水号
  personId: number // 业务员id
  customerId: number // 客户id
  orderDate: Date // 订单日期
  remark: string // 备注
}

// 销售订单主 API
export const SaleOrderApi = {
  // 查询销售订单主分页
  getSaleOrderPage: async (params: any) => {
    return await request.get({ url: `/wms/sale-order/page`, params })
  },

  // 查询销售订单主详情
  getSaleOrder: async (id: number) => {
    return await request.get({ url: `/wms/sale-order/get?id=` + id })
  },

  // 新增销售订单主
  createSaleOrder: async (data: SaleOrderVO) => {
    return await request.post({ url: `/wms/sale-order/create`, data })
  },

  // 修改销售订单主
  updateSaleOrder: async (data: SaleOrderVO) => {
    return await request.put({ url: `/wms/sale-order/update`, data })
  },

  // 删除销售订单主
  deleteSaleOrder: async (id: number) => {
    return await request.delete({ url: `/wms/sale-order/delete?id=` + id })
  },

  // 导出销售订单主 Excel
  exportSaleOrder: async (params) => {
    return await request.download({ url: `/wms/sale-order/export-excel`, params })
  },

  // 查询可以销售出库的销售订单
  findSaleOrderOperateList: async () => {
    return await request.get({ url: `/wms/sale-order/findSaleOrderOperateList`})
  },
         //提交
         submit: async (id: number) => {
          return await request.get({ url: `/wms/sale-order/startProcess?id=` + id })
        },

// ==================== 子表（销售订单子） ====================

  // 获得销售订单子列表
  getSaleDetailListByPid: async (pid) => {
    return await request.get({ url: `/wms/sale-order/sale-detail/list-by-pid?pid=` + pid })
  },

  getSaleDetialById: async (id) => {
    return await request.get({ url: `/wms/sale-order/getSaleDetialById?id=`+id })
  },


  
}
